home *** CD-ROM | disk | FTP | other *** search
- unit code;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- LblBeskjed: TLabel;
- EdtGjett: TEdit;
- BtnGjett: TButton;
- BtnStart: TButton;
- procedure BtnStartClick(Sender: TObject);
- procedure BtnGjettClick(Sender: TObject);
- private
- { Private declarations }
- Tilfeldig: Integer;
- Forsoek: Integer;
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.BtnStartClick(Sender: TObject);
- begin
- randomize;
- Tilfeldig := Random(20);
- Forsoek := 0;
-
- LblBeskjed.Caption := 'Gjett et tall mellom 1 og 20';
-
- end;
-
- procedure TForm1.BtnGjettClick(Sender: TObject);
- var
- Gjett :Integer;
-
- begin
- Gjett := StrToInt(EdtGjett.Text);
- Forsoek := Forsoek + 1;
-
- if Gjett = Tilfeldig then
- LblBeskjed.Caption := 'Du gjettet tallet i ' +
- IntToStr(Forsoek) + '. fors°k!';
-
- if Gjett < Tilfeldig then
- LblBeskjed.Caption := 'Tallet ' + IntToStr(Gjett) + ' er mindre enn "X"';
-
- if Gjett > Tilfeldig then
- LblBeskjed.Caption := 'Tallet ' + IntToStr(Gjett) + ' er st°rre enn "X"';
- end;
-
- end.
-